#pragma once

#define INITGUID

#include "d3dx10.h"
#include "IEngineComponent.h"
#include "Model.h"
#include "ModelLoader.h"

#pragma comment(linker, "/INCLUDE:??0RenderComponent@@QAE@XZ")

// {C659400B-BF89-413b-BE44-A6CECB366E1C}
DEFINE_GUID(RENDER_COMPONENT_GUID, 
0xc659400b, 0xbf89, 0x413b, 0xbe, 0x44, 0xa6, 0xce, 0xcb, 0x36, 0x6e, 0x1c);

class RenderComponent : public IEngineComponent
{
public:
	RenderComponent();
	RenderComponent(char* path, D3DXQUATERNION rotation, D3DXVECTOR3 scale, D3DXVECTOR3 position);

	EnginePointer<Model> getModel();
	GUID getSystemIdentifier();
	GUID getComponentIdentifier();
	HRESULT LoadModel(EnginePointer<ModelLoader> pModelLoader);
	void setModelPath(char* modelPath);
	D3DXMATRIX getWorld();
	void clearRotation();
	void setRotation(D3DXQUATERNION rotation);
	void rotate(D3DXVECTOR3 axis, float angle);
	D3DXQUATERNION getRotation();
	void clearPosition();
	void setPosition(D3DXVECTOR3 position);
	void move(D3DXVECTOR3 movement);
	D3DXVECTOR3 getPosition();
	void clearScale();
	void setScale(D3DXVECTOR3 scale);
	void doScale(D3DXVECTOR3 scale);
	D3DXVECTOR3 getScale();

	void Serialize(EnginePointer<ISerializerWriteContext>& context, char* name);
	static IEngineComponent* Deserialize(EnginePointer<ISerializerReadContext>& context);

	AUTO_SIZE;
private:
	char* modelPath;
	D3DXQUATERNION rotation;
	D3DXVECTOR3 scale;
	D3DXVECTOR3 position;
	EnginePointer<Model> model;
};
